package Day14;

import java.util.Scanner;

public class Text1 {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws AgeException, NameException {
        Girl g1 = new Girl();
        while (true) {
            try {
                System.out.println("请输入女朋友的姓名");
                String name = sc.nextLine();
                g1.setName(name);
                System.out.println("请输入女朋友的年龄");
                String str = sc.nextLine();
                int age = Integer.parseInt(str);
                g1.setAge(age);
                break;
            } catch (NameException e) {
                e.printStackTrace();
                continue;
            } catch (AgeException e) {
                e.printStackTrace();
                continue;
            }
        }

        System.out.println("女朋友的姓名是" + g1.getName()+ ", 女朋友的年龄是" + g1.getAge());

    }
}
